import type { ProductSeries } from "@/pages/base/series/entity";
import apiClient from "../../apiClient";

export interface PageListReq {
	name?: string;
	page: number;
	pageSize: number;
}

export interface PageListRes {
	total: number;
	records: ProductSeries[];
}

const pageList = (data: PageListReq) => apiClient.post<PageListRes>({ url: "/base/series/pageList", data });
const getInfo = (id: React.Key) => apiClient.get<ProductSeries>({ url: `/base/series/${id}` });
const add = (data: ProductSeries) => apiClient.post<ProductSeries>({ url: "/base/series", data });
const update = (data: ProductSeries) => apiClient.put<ProductSeries>({ url: "/base/series", data });
const remove = (ids: React.Key[]) => apiClient.delete({ url: "/base/series", params: { ids: ids.join(",") } });

// 获取下拉列表
const selectList = (): Promise<ProductSeries[]> =>
	apiClient.get({
		url: "/base/series/selectList",
	});

export default {
	pageList,
	selectList,
	getInfo,
	add,
	update,
	remove,
};
